import { Module } from '@nestjs/common';
import { MqttBrokerService } from './mqtt-broker.service';
import { ConfigureModule, ConfigureService } from '@app/configure';
import { PigeonModule, Transport } from '@alecmmiller/pigeon-mqtt-nest';

@Module({
  imports: [
    ConfigureModule,
    PigeonModule.forRootAsync({
      imports : [ConfigureModule],
      inject : [ConfigureService],
      useFactory : (config:ConfigureService) => {
        const port = config.get('mqtt.port')
        return {
          transport : Transport.TCP,
          port : port,
          ...config.get('mqtt.broker')
        }
      }
    }),

    
  ],
  providers: [MqttBrokerService],
})
export class MqttBrokerModule {}
